<script setup>
import { useStore } from 'vuex'

// 创建 store 对象
const store = useStore()


function addClick() {
    store.commit('add')
    // this.$
}
function addActionClick() {
    store.dispatch('addNumAction', 1)
}

function change() {
    store.commit('changePhoneName', '不知道')
}
</script>
<template>
    <div>
        <el-button @click="addClick">加 1</el-button>
        <el-button @click="addActionClick">异步加 1</el-button>
        <h1>Vue Hooks 管理</h1>
        <h2> {{ store.state.count }} </h2>
        <h2> {{ store.getters.dCount }} </h2>

        <hr />
        <el-button @click="change">修改手机名称</el-button>
        <h2>
            {{ store.state.phone.name }}
        </h2>

    </div>
</template>